#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

constexpr int MAXN = 100000 + 11;

struct Car {
    int d, v, a;
} car[MAXN];
int p[MAXN];

namespace subtask2 {
    constexpr int N = 20 + 11;
    
    int val[N];

    void solve(int n, int m, int v) {
        memset(val, 0, sizeof(val));

        ll vt2 = 1ll * v * v;

        int cnt = 0, tars = 0;
        for (int i = 1; i <= n; ++i) {
            int d = car[i].d, v0 = car[i].v, a = car[i].a;
            bool flag = false;
            if (a < 0) {
                ll go = 1ll * a * v0 * v0 + 2ll * (1ll * v0 * v0 * -a + 1ll * d * -a * -a);
                for (int j = 1; j <= m; ++j) if (d <= p[j] && 2ll * p[j] * -a * -a <= go) {
                    int s = p[j] - d;
                    ll pvt2 = 1ll * v0 * v0 + 2ll * a * s;
                    if (pvt2 > vt2) {
                        flag = true;
                        val[j] |= 1 << i;
                    }
                }
            } else {
                for (int j = 1; j <= m; ++j) if (d <= p[j]) {
                    int s = p[j] - d;
                    ll pvt2 = 1ll * v0 * v0 + 2ll * a * s;
                    if (pvt2 > vt2) {
                        flag = true;
                        val[j] |= 1 << i;
                    }
                }
            }
            if (flag) {
                ++cnt;
                tars |= 1 << i;
            }
        }

        auto dfs = [&](auto &self, int dep, int nows) {
            if (dep == m + 1) {
                return nows == tars ? 0 : -114514;
            }

            return max(self(self, dep + 1, nows | val[dep]), self(self, dep + 1, nows) + 1);
        };

        cout << cnt << ' ' << dfs(dfs, 1, 0) << '\n';
    }
}
namespace subtask34 {
    void solve(int n, int m, int v) {
        ll vt2 = 1ll * v * v;

        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            int d = car[i].d, v0 = car[i].v, a = car[i].a, s = p[m] - d;
            if (s < 0) {
                continue;
            }
            ll pvt2 = 1ll * v0 * v0 + 2ll * a * s;
            cnt += pvt2 > vt2;
        }
        cout << cnt << ' ' << m - 1 + (!cnt) << '\n';
    }
}

void solve() {
    //multitest please clear!
    int n, m, l, v;
    cin >> n >> m >> l >> v;
    bool subtask34 = true;
    for (int i = 1; i <= n; ++i) {
        cin >> car[i].d >> car[i].v >> car[i].a;
        subtask34 &= car[i].a >= 0;
    }
    for (int i = 1; i <= m; ++i) {
        cin >> p[i];
    }
    if (subtask34) {
        subtask34::solve(n, m, v);
        return ;
    }
    subtask2::solve(n, m, v);
}

//Hey I'm SkyWave!
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    // Must not forget these!

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}